<%@page import="com.register.beans.RegisterBean"%>
<%@page import="com.register.dao.RegisterDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String userid = request.getParameter("userid");
	String passwd = request.getParameter("passwd");

	RegisterDAO dao = new RegisterDAO();
	RegisterBean memberInfo = dao.searchMember(userid.toLowerCase(),passwd);
	request.setAttribute("memberInfo", memberInfo);

	if (memberInfo.getId() != null) {
%>
<style>
<!--
td {
	text-align: center;
}

/* td:FIRST-CHILD { */
/* 	background-color: #FAFAFA; */
/* } */


-->
</style>

<script type="text/javascript">
$(document).ready(function(){
	
	$("#btnMemberList").click(function() {
		$.ajax({
			url : "ajax_memberList.forrest",
			dataType : "json",
			error : function(e) {
				alert("ajax_memberList.forrest error");
				alert(e.responseText);
			},
			success : dataToHTML
		});
		
		function dataToHTML(data){
// 			alert(data);
			var dataHTML = "<table style='width: 400px; border: 1px;' border='1'>";
			dataHTML += "<thead>	<tr><th width='100' align='center'>이름</th><th width='120' align='center'>ID</th><th width='120' align='center'>생년월일</th>";
			dataHTML += "</tr></thead>";
			dataHTML += "<tbody>";
			for(var i=0; i<data.length; i++){
				dataHTML += "<tr><td align='center'>" +data[i].name + "</td>";
				dataHTML += "<td align='center'>" +data[i].id + "</td>";
				dataHTML += "<td align='center'>" +data[i].birth + "</td></tr>";
			}
// 			dataHTML += "<tr><td colspan='3' style='background-color: white;'><input type='button' id='btnMemberInfo' value='회원 정보'></td></tr>";
			dataHTML += "</tbody></table>";
			$("#memeberInfo").hide(1000);
			$("#memeberList").html(dataHTML);
			$("tr").filter(function(idx){
				return idx % 5==0;
			}).css("background", "#a566ff");
// 			$("tr:odd").css("background", "#ffd8d8");
			
// 			console.log(dataHTML);
		}
		
		
		
	});
});
</script>
<div id="div0">
	<table style="width: 300px; border: 1px gray solid;" border="0">
		<tr>
			<td width="100" height="100" align="center" rowspan="2"><img src="${memberInfo.imgPath }" id="imgPath" name="imgPath"></td>
			<td width="120"></td>
		</tr>

	</table>
</div>
<div id="div1">
		<table style="width: 300px; border: 1px gray solid;" border="0">
		<tr>
			<td width="100" align="center">이름</td>
			<td width="120" align="center">${memberInfo.name }</td>
		<tr>
		<tr>
			<td align="center">아이디</td>
			<td align="center">${memberInfo.id }</td>
		<tr>
		<tr>
			<td>비밀번호</td>
			<td>${memberInfo.passWd }</td>
		<tr>
		<tr>
			<td>이메일</td>
			<td>${memberInfo.email }</td>
		<tr>
		<tr>
			<td>성별</td>
			<td align="left">${memberInfo.sex }</td>
		<tr>
		<tr>
			<td>생년월일</td>
			<td>${memberInfo.birthDate }</td>
		<tr>
		<tr>
			<td>핸드폰</td>
			<td>${memberInfo.cellPhone }</td>
		<tr>
		<tr>
			<td colspan="2" style="background-color: white;"><input type="button" id="btnMemberList" value="회원 목록"></td>
			
		<tr>
	</table>
</div>
<%
	} else {
		out.println("null");
	}
%>
